<?php

class Quantri_KhuvucController extends Zend_Controller_Action
{

    public function init()
    {
        $option=array(
        		"layout" => "layout",
        		"layoutPath" => APPLICATION_PATH."/layouts/scripts/quantri"
        );
        Zend_Layout::startMvc($option);
        
        $this->view->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8');
    }

    public function indexAction()
    {
        $Khuvuc = new Quantri_Model_KhuVuc();
        $rsKhuvuc = $Khuvuc->GetAll();
         
        $this->view->rsKhuvuc = $rsKhuvuc->toArray();
    }

    public function themkhuvucAction()
    {
        $this->_helper->layout()->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);

        $khuvuc = new Quantri_Model_Khuvuc();
        
        $Id = $this->_request->getParam("idKhuvuc","-1");
        $ten = $this->_request->getParam("ten","");       
        $trangthai = $this->_request->getParam("trangthai","");
        
        $khuvuc->Id=$Id;
        $khuvuc->Ten = $ten;        
        $khuvuc->TrangThai = $trangthai;
        
        $khuvuc->themkhuvuc();
    }
    public function xoakhuvucAction()
    {
    	$this->_helper->layout()->disableLayout();
    	$this->_helper->viewRenderer->setNoRender(true);
    
    	$khuvuc = new Quantri_Model_Khuvuc();
    	$id = $this->_request->getParam("id", "-1");
    
    	$khuvuc->XoaKhuvuc($id);
    }
    public function suaAction()
    {
    	$this->_helper->layout()->disableLayout();
    	$this->_helper->viewRenderer->setNoRender(true);
    
    	$idKhuvuc = $this->_request->getParam("id","-1");
    
    	$khuvuc = new Quantri_Model_Khuvuc();
    	$khuvuc->Id = $idKhuvuc;
    
    	$rsKhuvuc = $khuvuc->GetById();
    
    	//var_dump($rsKhuvuc[0]);
    	echo json_encode($rsKhuvuc);
    }

}



